<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
namespace Agp\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use APY\DataGridBundle\Grid\Mapping as GRID;

/**
 * Agp\CoreBundle\Entity\Layout
 *
 * @ORM\Table(name="layout")
 * @ORM\Entity(repositoryClass="Agp\CoreBundle\Repository\LayoutRepository")
 * @UniqueEntity(fields={"descricao", "empresa"})
 * 
 * @GRID\Source(columns="codLayout, descricao")
 */
class Layout
{
    /**
     * @var integer $codAtendente
     *
     * @ORM\Column(name="cod_layout", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @GRID\Column(title="Código", visible=false, type="text", size="5", primary=true)
     */
    protected $codLayout;
    
    /**
     * @var string $descricao
     * 
     * @ORM\Column(name="descricao", type="string", length=42, nullable=true)
     * 
     * @GRID\Column(title="Nome", type="text")
     * 
     */
    protected $descricao;
    
    /**
     * @var object $layout
     *
     * @ORM\ManyToOne(targetEntity="Empresa", fetch="LAZY")
     * @ORM\JoinColumn(name="cod_empresa", referencedColumnName="cod_empresa", onDelete="Cascade", nullable=false)
     */
    protected $empresa;
    
    /**
     *
     * @ORM\OneToMany(targetEntity="LayoutTicket", mappedBy="layout", cascade={"all"})
     */
    protected $layoutReference;
    
    public function getCodLayout() {
        return $this->codLayout;
    }

    public function setCodLayout($codLayout) {
        $this->codLayout = $codLayout;
    }

    public function getDescricao() {
        return $this->descricao;
    }

    public function setDescricao($descricao) {
        $this->descricao = mb_strtoupper($descricao, 'UTF-8');
    }
    
    public function getEmpresa() {
        return $this->empresa;
    }

    public function setEmpresa($empresa) {
        $this->empresa = $empresa;
    }
   
    /**
     * Add $layoutReference
     *
     * @param Agp\CoreBundle\Entity\TerminalLayout $layoutReference
     */
    public function addLayoutReference(\Agp\CoreBundle\Entity\LayoutTicket $layoutReference)
    {
        $this->layoutReference[] = $layoutReference;
    }

    /**
     * Get layoutReference
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getLayoutReference()
    {
        return $this->layoutReference;
    }
    
}

?>
